﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace 学生成绩查询及选课系统
{
    public partial class MainPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Label1.Text = "欢迎用户:" + Session["user"].ToString();
            }
        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            Response.Redirect("./student/studentMainView.aspx");
        }

        protected void LinkButton2_Click(object sender, EventArgs e)
        {
            string startTime = DateTime.Now.ToString("yyyy-06-10");
            string overTime = DateTime.Now.ToString("yyyy-07-10");
            DateTime startTime1 = Convert.ToDateTime(startTime);
            DateTime overTim1 = Convert.ToDateTime(overTime);
            string sql = "select count(*) from student where stustate=0 and stuno=" + Session["user"].ToString();
            object res = DBAccess.GetOne(sql);

            string nowsday = DateTime.Now.ToString("yyyy-MM-dd");
            DateTime nowsday1 = Convert.ToDateTime(nowsday);
            if (DateTime.Compare(nowsday1, startTime1) < 0 || DateTime.Compare(nowsday1, overTim1) > 0)
            {
                Response.Write("<script>alert('您已过了选课时间段,该界面已关闭！或该系统暂未开放');</script>");
            }
            else
            {
                if ((int)res != 0)
                {
                    
                    Response.Write("<script>alert('您已毕业或不在学校就读!');</script>");
                }
                else
                {
                    Response.Redirect("studetnOption/optionCourse.aspx");
                }
            }

        }

        protected void LinkButton3_Click(object sender, EventArgs e)
        {
            Response.Redirect("./login.aspx");
        }
    }
}